package com.ysx.oa.role.service.impl;


import com.ysx.oa.role.bean.RoleBean;
import com.ysx.oa.role.bean.RoleUserBean;
import com.ysx.oa.role.bean.UserBean;
import com.ysx.oa.role.dao.RoleDao;
import com.ysx.oa.role.dao.UserRoleDao;
import com.ysx.oa.role.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.dc.pr.PRError;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDao dao;
    @Autowired
    private UserRoleDao userRoleDao;

    @Override
    public RoleBean findById(Integer id) {
        RoleBean bean = new RoleBean();
        bean.setId(id);
        return dao.selectOne(bean);
    }

    @Override
    public int add(RoleBean bean) {
        return dao.insert(bean);
    }

    @Override
    public int sum(int x, int y) {
        System.out.println("进入role模块...");
        int sum = x+y;
        return sum;
    }


   /* @Override
    public List<RoleUserBean> findAllRole(Integer userId) {
        RoleUserBean roleUserBean=new RoleUserBean();
        roleUserBean.setUserId(userId);
        RoleUserBean roleUserBeans = userRoleDao.selectOne(roleUserBean);
        Integer roleId = roleUserBeans.getRoleId();
        RoleBean roleBean=new RoleBean();
        roleBean.setId(roleId);
        RoleBean select = dao.selectOne(roleBean);
        String roleName = select.getRoleName();
        if(roleName.equals("系统管理员")){
            List<RoleUserBean> allRole = userRoleDao.selectAll();
            System.out.println(allRole);
            return allRole;
        }
        return null;
    }*/
}
